package com.knowif.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.validation.annotation.Validated;

@Validated
public class UserCollect {
    private Integer id;

    private Integer beCollectedUserId;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @NotEmpty(message = "用户id不能为空")
    private Integer userId;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getBeCollectedUserId() {
        return beCollectedUserId;
    }

    public void setBeCollectedUserId(Integer beCollectedUserId) {
        this.beCollectedUserId = beCollectedUserId;
    }

    public Date getCreateTime() {
    	if(createTime == null){
    		createTime = new Date();
    	}
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public static List<Integer> getUserIds(List<UserCollect> userCollects){
    	if(userCollects == null || userCollects.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> userIds = new ArrayList<Integer>();
		for (UserCollect userCollect : userCollects) {
			userIds.add(userCollect.getBeCollectedUserId());
		}
		return userIds;
    }
    
    
    public static List<Integer> getUserCollectIds(List<UserCollect> userCollects){
    	if(userCollects == null || userCollects.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> ids = new ArrayList<Integer>();
		for (UserCollect userCollect : userCollects) {
			ids.add(userCollect.getId());
		}
		return ids;
    }

    
	@Override
	public String toString() {
		return "UserCollect [id=" + id + ", beCollectedUserId=" + beCollectedUserId + ", createTime=" + createTime
				+ ", userId=" + userId + "]";
	}
    
    
}